@extends('admin.formLayout')

@section('title','设备详情')
@section('barName','设备详情')
    @section('content')
        <div class="layui-container">
            <blockquote class="layui-elem-quote">
             <div class="layui-row">
                 设备Id: <span>{{$device->device_id}}</span>
             </div>

              

            </blockquote>

            <fieldset class="layui-elem-field layui-field-title">
                <legend>ID详情(<a  href="https://mp.weixin.qq.com/cgi-bin/readtemplate?t=ibeacon/rule_tmpl&token=1665986394&lang=zh_CN#section2">使用说明</a>)</legend>
            </fieldset>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">UUID</div>
                </div>
                <div class="layui-col-xs8">
                    <div class="grid-demo">{{$device->uuid}}</div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">Major</div>
                </div>
                <div class="layui-col-xs8">
                    <div class="grid-demo">{{$device->major}}</div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">Minor</div>
                </div>
                <div class="layui-col-xs8">
                    <div class="grid-demo">{{$device->minor}}</div>
                </div>
            </div>
            <fieldset class="layui-elem-field layui-field-title">
                <legend>设备详情</legend>
            </fieldset>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">绑定景点</div>
                </div>

                <div class="layui-col-xs8">
                    <div class="grid-demo">
                            <span id="page_title">{{$device->spot->title or ''}}</span>
<a style="color: #00aced" href="javascript:void(0)" onclick="bind()">绑定景点</a>


                    </div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">设备备注</div>
                </div>

                <div class="layui-col-xs8">
                    <div class="grid-demo">
                        <span id="comment">{{$device->comment}}</span>
                        <a style="color: #00aced" href="javascript:void(0)" onclick="edit_comment()">编辑</a>
                    </div>
                </div>
            </div>
            <div class="layui-row">
                <p align="center"><a href="{{route('admin.device')}}" class="layui-btn layui-btn-primary">返回列表</a></p>
            </div>
        </div>
<script>
    var layer;
    var $;
    layui.use(['table','jquery','form','layer'],function(){
        layer=layui.layer;
        $=layui.jquery;
    })
    function bind() {

            layer.open({
                type: 2,
                title: '选择景点',
                 //不显示关闭按钮
                shade: [0],
                area: ['860px', '400px'],
                anim: 2,
                content: ['{{route('admin.device.spot',['device_id'=>$id])}}'], //iframe的url，no代表不显示滚动条
            });

    }
    function edit_comment(){
        layer.prompt({title: '请输入备注'}, function(comment, index){
            if(comment==''){
                layer.alert('请输入备注');
                return ;
            }
            $.get('{{route('admin.device.edit',['device_id'=>$id])}}',{comment:comment},function(data){
                if(data.info=='success'){
                    $("#comment").html(comment);
                    layer.close(index);
                }else{
                    layer.alert(data.msg);

                }
            });


        });

    }
</script>
        @endsection
